package com.pocket.insight.base.sql.dataset;

import org.apache.commons.lang3.tuple.Pair;

import java.util.Map;

/**
 * 描述：
 *
 * @author shuize
 * @create 2024/12/13
 */
public class RuntimeData {
    private Map<Long, DatasetResource>        shareResourceMap;
    private Map<String, Pair<String, String>> shareWithMap;
    private boolean                           applyDatasetAcl = true;
    private boolean                           applyParentAcl  = true;

    public RuntimeData(Map<Long, DatasetResource> shareResourceMap, Map<String, Pair<String, String>> shareWithMap, boolean applyDatasetAcl) {
        this.shareResourceMap = shareResourceMap;
        this.shareWithMap = shareWithMap;
        this.applyDatasetAcl = applyDatasetAcl;
    }

    public RuntimeData(Map<Long, DatasetResource> shareResourceMap, Map<String, Pair<String, String>> shareWithMap) {
        this.shareResourceMap = shareResourceMap;
        this.shareWithMap = shareWithMap;
    }

    public RuntimeData() {
    }

    public Map<Long, DatasetResource> getShareResourceMap() {
        return this.shareResourceMap;
    }

    public RuntimeData setShareResourceMap(Map<Long, DatasetResource> shareResourceMap) {
        this.shareResourceMap = shareResourceMap;
        return this;
    }

    public Map<String, Pair<String, String>> getShareWithMap() {
        return this.shareWithMap;
    }

    public RuntimeData setShareWithMap(Map<String, Pair<String, String>> shareWithMap) {
        this.shareWithMap = shareWithMap;
        return this;
    }

    public boolean isApplyDatasetAcl() {
        return this.applyDatasetAcl;
    }

    public RuntimeData setApplyDatasetAcl(boolean applyDatasetAcl) {
        this.applyDatasetAcl = applyDatasetAcl;
        return this;
    }

    public RuntimeData copyWithoutApplicableDatasetAcl() {
        RuntimeData runtimeData = new RuntimeData();
        runtimeData.shareResourceMap = this.shareResourceMap;
        runtimeData.shareWithMap = this.shareWithMap;
        runtimeData.applyDatasetAcl = false;
        return runtimeData;
    }

    public RuntimeData copyWithoutResourceMap() {
        return this.copyWithoutApplicableDatasetAcl().setShareResourceMap(null);
    }

    public boolean isApplyParentAcl() {
        return this.applyParentAcl;
    }

    public RuntimeData setApplyParentAcl(boolean applyParentAcl) {
        this.applyParentAcl = applyParentAcl;
        return this;
    }
}
